package thread;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
public class TCPServer {
    public static void main(String args[]) throws Exception{
        String nhan;
        String gui;
        ServerSocket welcomeSocket=new ServerSocket(9999);
        System.out.println("Server lang nghe ket noi tai cong: "+welcomeSocket);
        while(true)
        {
            Socket client=welcomeSocket.accept();
            BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
            DataOutputStream out = new DataOutputStream(client.getOutputStream());
            nhan=in.readLine();
            System.out.println("Da nhan tu Client: "+nhan);
            gui=nhan.toUpperCase()+'\n';
            System.out.println("Gui lai client: "+gui);
            out.writeBytes(gui);
        }
    }
}
